package com.server.commons.huawei_obs.enums;

import com.server.common.code.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum HuaweiOBSLocationEnum {
    AF_SOUTH1       ("非洲-约翰内斯堡","af-south-1","obs.af-south-1.myhuaweicloud.com"),
    CN_NORTH4       ("华北-北京四","cn-north-4","obs.cn-north-4.myhuaweicloud.com"),
    CN_NORTH1       ("华北-北京一","cn-north-1","obs.cn-north-1.myhuaweicloud.com"),
    CN_NORTH9       ("华北-乌兰察布一","cn-north-9","obs.cn-north-9.myhuaweicloud.com"),
    CN_EAST2        ("华东-上海二","cn-east-2","obs.cn-east-2.myhuaweicloud.com"),
    CN_EAST3        ("华东-上海一","cn-east-3","obs.cn-east-3.myhuaweicloud.com"),
    CN_SOUTH1       ("华南-广州","cn-south-1","obs.cn-south-1.myhuaweicloud.com"),
    LA_NORTH2       ("拉美-墨西哥城二","cn-south-1","obs.la-north-2.myhuaweicloud.com"),
    NA_MEXICO1      ("拉美-墨西哥城一","na-mexico-1","obs.na-mexico-1.myhuaweicloud.com"),
    SA_BRAZIL1      ("拉美-圣保罗一","sa-brazil-1","obs.sa-brazil-1.myhuaweicloud.com"),
    LA_SOUTH2       ("拉美-圣地亚哥","la-south-2","obs.la-south-2.myhuaweicloud.com"),
    TR_WEST1        ("土耳其-伊斯坦布尔","tr-west-1","obs.tr-west-1.myhuaweicloud.com"),
    CN_SOUTHWEST2   ("西南-贵阳一","cn-southwest-2","obs.cn-southwest-2.myhuaweicloud.com"),
    AP_SOUTHEAST2   ("亚太-曼谷","ap-southeast-2","obs.ap-southeast-2.myhuaweicloud.com"),
    AP_SOUTHEAST3   ("亚太-新加坡","ap-southeast-3","obs.ap-southeast-3.myhuaweicloud.com"),
    AP_SOUTHEAST1   ("中国-香港","ap-southeast-1","obs.ap-southeast-1.myhuaweicloud.com"),

    ;

    private final String name;
    private final String location;
    private final String endPoint;

    /**
     * @return 枚举类
     */
    public static HuaweiOBSLocationEnum getByLocation(String location) {
        if (StringUtils.isEmpty(location)) {
            return null;
        }
        for (HuaweiOBSLocationEnum huaweiOBSLocationEnum : HuaweiOBSLocationEnum.values()) {
            if (location.equalsIgnoreCase(huaweiOBSLocationEnum.getLocation())) {
                return huaweiOBSLocationEnum;
            }
        }
        return null;
    }

    /**
     * @return 枚举类
     */
    public static HuaweiOBSLocationEnum getByName(String name) {
        if (StringUtils.isEmpty(name)) {
            return null;
        }
        for (HuaweiOBSLocationEnum huaweiOBSLocationEnum : HuaweiOBSLocationEnum.values()) {
            if (name.equalsIgnoreCase(huaweiOBSLocationEnum.getName())) {
                return huaweiOBSLocationEnum;
            }
        }
        return null;
    }

    /**
     * @return 枚举类
     */
    public static HuaweiOBSLocationEnum getByEndPoint(String endPoint) {
        if (StringUtils.isEmpty(endPoint)) {
            return null;
        }
        for (HuaweiOBSLocationEnum huaweiOBSLocationEnum : HuaweiOBSLocationEnum.values()) {
            if (endPoint.equalsIgnoreCase(huaweiOBSLocationEnum.getEndPoint())) {
                return huaweiOBSLocationEnum;
            }
        }
        return null;
    }


}
